builder: Make GListStore buildable
authorBenjamin Otte <otte@redhat.com>
Tue, 4 Jun 2019 03:54:16 +0000 (05:54 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 4 Jun 2019 04:11:44 +0000 (06:11 +0200)
Treats GListStore like any other object and allows <child> to add items
to it.

gtk/gtkbuilder.c

index 2f5ba245e938874bb4c673bdf5a950c211e6404e..63cb6a6a2e8aee3be99a251e8fea741f238cf836 100644 (file)
@@ -925,13 +925,27 @@ _gtk_builder_add (GtkBuilder *builder,
   g_assert (object != NULL);
 
   parent = ((ObjectInfo*)child_info->parent)->object;
-  g_assert (GTK_IS_BUILDABLE (parent));
 
   GTK_NOTE (BUILDER,
             g_message ("adding %s to %s", object_get_name (object), object_get_name (parent)));
 
-  gtk_buildable_add_child (GTK_BUILDABLE (parent), builder, object,
-                           child_info->type);
+  if (G_IS_LIST_STORE (parent))
+    {
+      if (child_info->type != NULL)
+        {
+          GTK_BUILDER_WARN_INVALID_CHILD_TYPE (parent, child_info->type);
+        }
+      else
+        {
+          g_list_store_append (G_LIST_STORE (parent), object);
+        }
+    }
+  else
+    {
+      g_assert (GTK_IS_BUILDABLE (parent));
+      gtk_buildable_add_child (GTK_BUILDABLE (parent), builder, object,
+                               child_info->type);
+    }
 
   child_info->added = TRUE;
 }